﻿using RFID.BLL;
using RFID.Model;
using System;

namespace RFID.PC.CardCenter
{
    public partial class AddCardForm : ChildForm
    {
        public AddCardForm(MainForm main, object sender)
            : base(main, sender)
        {
            InitializeComponent();
            Text = Title;
        }

        private void AddCardForm_Load(object sender, EventArgs e)
        {
            cmbStu.DataSource = StuInfoBLL.Select();
            cmbStu.DisplayMember = "Name";
            cmbStu.ValueMember = "Id";
        }

        private void TxtCard_DoubleClick(object sender, EventArgs e)
        {
            GetTagIdByDoubleClick(sender);
        }

        private void BtnOK_Click(object sender, EventArgs e)
        {
            CardInfo card = new CardInfo()
            {
                Id = txtCard.Text,
                Sid = int.Parse(cmbStu.SelectedValue.ToString()),
                Rich = decimal.Parse(txtMoney.Text),
                Pwd = txtPwd.Text,
                Disabled = false,
                IsDelete = false
            };
            var result = CardInfoBLL.AddCard(card);
            ShowResult(result);
        }
    }
}
